package com.mf.all.controller;


import com.mf.all.groups.GroupsAddInterface;
import com.mf.all.groups.GroupsUpdateInterface;
import com.mf.all.result.Result;
import com.mf.all.utils.UtilController;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import cn.dev33.satoken.annotation.SaCheckPermission;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

    
import com.mf.all.entity.dto.DtoInOutRecord;
import com.mf.all.entity.req.ReqInOutRecord;
import com.mf.all.service.ServiceInOutRecord;
import com.mf.all.entity.req.search.SearchReqInOutRecord;

import java.util.Arrays;
import java.util.List;

/**
 * 出入库记录
 * @date 2025-04-02 22:36:47
 */
@RestController
@RequestMapping("inoutrecord" )
@Tag(name = "出入库记录" )
public class ControllerInOutRecord {
    @Resource
    private ServiceInOutRecord ServiceinOutRecord;

    @Operation(summary = "分页列表查询" )
    @PostMapping("/page" )
    @SaCheckPermission("inoutrecord:search")
    public Result<Page<DtoInOutRecord>> findPage(@RequestBody SearchReqInOutRecord searchReqInOutRecord) {
        return Result.success(ServiceinOutRecord.findPageByParams(searchReqInOutRecord));
    }

    @Operation(summary = "列表查询" )
    @PostMapping("/list" )
    @SaCheckPermission("inoutrecord:search")
    public Result<List<DtoInOutRecord>> list(@RequestBody SearchReqInOutRecord searchReqInOutRecord) {
        return Result.success(ServiceinOutRecord.findListByParams(searchReqInOutRecord));
    }

    @Operation(summary = "保存" )
    @PostMapping("/save" )
    @SaCheckPermission("inoutrecord:save")
    public Result<Void> save(@Validated(GroupsAddInterface.class) @RequestBody ReqInOutRecord reqInOutRecord) {
        ServiceinOutRecord.save(UtilController.setBo(reqInOutRecord, DtoInOutRecord.class));
        return Result.success();
    }

    @Operation(summary = "修改" )
    @PostMapping("/update" )
    @SaCheckPermission("inoutrecord:update")
    public Result<Void> update(@Validated(GroupsUpdateInterface.class) @RequestBody ReqInOutRecord reqInOutRecord) {
        ServiceinOutRecord.updateById(UtilController.setBo(reqInOutRecord, DtoInOutRecord.class));
        return Result.success();
    }

    @Operation(summary = "删除" )
    @PostMapping("/delete" )
    @SaCheckPermission("inoutrecord:delete")
    public Result<Void> delete(@RequestBody Integer[] ids) {
        ServiceinOutRecord.removeByIds(Arrays.asList(ids));
        return Result.success();
    }

}
